home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6798 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: dawn.mmm.com!news
  2. From: kjhopps@mmm.com (Kevin J Hopps)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: strcpy problem
  5. Date: 19 Feb 1996 20:20:06 GMT
  6. Organization: 3M - St. Paul, MN  55144-1000 US
  7. Message-ID: <4gam1m$4q7@dawn.mmm.com>
  8. References: <31261C92.3DEE@intersurf.com>
  9. Reply-To: kjhopps@mmm.com
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. David C. Branton (dbranton@intersurf.com) wrote:
  13. > strcpy does not seem to work in this case. Can anyone explain why?
  14.  
  15. > Here is the setup:
  16.  
  17. > class league
  18. > { protected:
  19. >  ...
  20. >   struct franchise
  21. >   {...
  22. >     struct person
  23. >     {  char name [25];
  24. >        ...
  25. >     }
  26. >   }team [12];
  27. >    
  28. >   public:
  29. >   void draftplayer ();
  30. >   ...
  31. > }; 
  32.  
  33. > void league::draftplayer()
  34. > {
  35. >   char playername[25];
  36. >   ...
  37.  
  38. >   // playername is given a value; tracing confirms that it has a value
  39.  
  40. >   strcpy(team[draftpick-1].player[round-1].name, playername);
  41.  
  42. > ...
  43.  
  44. > }
  45.  
  46. > The line strcpy... does not copy the string. When code is traced, there 
  47. > is a proper value for playername but nothing gets copied into the nested 
  48. > structure.  All variable have been properly declared and have values at 
  49. > this point.
  50.  
  51. > Any ideas as to why strcpy does not work in this case?
  52.  
  53. Could it be too complicated an expression for your compiler? Perhaps you
  54. could break the expression into simpler statements. If this produces a
  55. better result, report a bug to your compiler vendor.
  56. --
  57. Kevin J. Hopps                  e-mail: kjhopps@mmm.com
  58. 3M Company                      phone:  (612) 737-4643
  59. 3M Center, Bldg. 235-2D-57      fax:    (612) 737-2700
  60. St. Paul, MN 55144-1000         Opinions are my own.  I don't speak for 3M.
  61.     But 3M speaks for me -- I did not write the following line:
  62.  
  63. Opinions expressed herein are my own and may not represent those of 3M.
  64.